package com.yst.gateway.monitor.common.token;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.apache.commons.lang.StringUtils;

import com.yst.gateway.monitor.common.utils.UUIDGenerator;

public class DefaultTokenManager implements TokenManager{
	
	private static Map<String, String> tokenMap = new ConcurrentHashMap<String, String>();
	
	@Override
	public String createToken(String username) {
		String token = UUIDGenerator.getUUID();
		tokenMap.put(token, username);
		return token;
	}
	
	@Override
	public boolean checkToken(String token){
		return StringUtils.isNotEmpty(token) &&tokenMap.containsKey(token);
	}
}
